"""AI Extraction schemas for property matching."""

from __future__ import annotations

from pydantic import BaseModel, Field


class LeadRequirements(BaseModel):
    """AI提取的结构化客户需求."""

    # 核心需求
    layout: str | None = Field(None, description="户型需求(如: 2室1厅, 三室两厅)")
    area_preferences: list[str] = Field(
        default_factory=list, description="区域偏好(如: ['望京','国贸'])"
    )
    budget_min: int | None = Field(None, description="预算下限(元/月)")
    budget_max: int | None = Field(None, description="预算上限(元/月)")

    # AI推理需求
    commute_location: str | None = Field(None, description="通勤地点(从'上班在XX'推断)")
    commute_max_minutes: int | None = Field(None, description="最大通勤时间(分钟)")

    # 标签需求 (分优先级)
    must_have_tags: list[str] = Field(
        default_factory=list, description="必须满足(如: ['近地铁','可养宠物'])"
    )
    nice_to_have_tags: list[str] = Field(
        default_factory=list, description="加分项(如: ['有电梯','朝南'])"
    )

    # 软性需求
    budget_flexibility: str = Field("normal", description="预算灵活度: strict|normal|flexible")
    urgency: str = Field("normal", description="紧迫程度: urgent|normal|flexible")

    # 元数据
    extraction_method: str = Field("hybrid", description="提取方法: rules|ai|hybrid")
    confidence: float = Field(0.8, ge=0, le=1, description="提取置信度")
    ai_raw_response: str | None = Field(None, description="AI原始响应(审计用)")


class PropertyFeatures(BaseModel):
    """AI提取的结构化房源特征."""

    # 配套设施 (具体化)
    facilities: list[str] = Field(
        default_factory=list, description="配套设施(如: ['地铁站500米','有电梯','允许养宠物'])"
    )

    # 周边环境
    nearby_landmarks: list[str] = Field(
        default_factory=list, description="周边地标(如: ['望京SOHO','14号线望京站'])"
    )
    nearby_business_districts: list[str] = Field(
        default_factory=list, description="邻近商圈(如: ['CBD','国贸'] - 用于通勤匹配)"
    )

    # 房源亮点
    highlights: list[str] = Field(
        default_factory=list, description="房源亮点(如: ['采光好','安静','精装修'])"
    )

    # 适合人群 (AI推断)
    suitable_for: list[str] = Field(
        default_factory=list, description="适合人群(如: ['上班族','家庭','学生'])"
    )

    # 元数据
    extraction_method: str = Field("hybrid", description="提取方法")
    confidence: float = Field(0.8, ge=0, le=1, description="提取置信度")
    ai_raw_response: str | None = Field(None, description="AI原始响应(审计用)")
